/* This file is part of SpaceSim.
 
 SpaceSim is free software: you can redistribute it and/or modify
 it under the terms of the GNU General Public License as published by
 the Free Software Foundation, either version 3 of the License, or
 (at your option) any later version.
 
 SpaceSim is distributed in the hope that it will be useful,
 but WITHOUT ANY WARRANTY; without even the implied warranty of
 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 GNU General Public License for more details.
 
 You should have received a copy of the GNU General Public License
 along with SpaceSim.  If not, see <http://www.gnu.org/licenses/>. */

#include <SFML/Graphics.hpp>

#include "control.h"
#include "entity.h"
#include "mission.h"
#include "planet.h"
#include "ship.h"

#ifndef PLAYER_H
#define PLAYER_H

#define ONE_ENT

class Player : public RotatableEntity, public Orbit {
private:
	Ship *ActiveShip;
	sf::Sprite Sprite;
	ShipControl::Enum ControlMode;
	int TargetPlanet;
	Planet *DockTarget;
	Mission ActiveMission;
public:
	Player() {
		TargetPlanet = 0;
		ActiveShip = NULL;
		XPos = 100.0;
		SetManualControl();
	}
	void SetShip(Ship *_ship) {
		ActiveShip = _ship;
		Sprite.SetImage(*(ActiveShip->GetImage()));
		Sprite.SetCenter(ActiveShip->GetImage()->GetWidth() / 2, ActiveShip->GetImage()->GetHeight() / 2);
	}
	sf::Sprite GetSprite() {
		return Sprite;
	}
	Planet *GetPlanet() {
		return DockTarget;
	}
	void SetMission(Mission _mission) {
		ActiveMission = _mission;
	}
	Mission *GetMission() {
		return &ActiveMission;
	}
	void Accelerate();
	void TurnLeft();
	void TurnRight();
	void Reverse();
	void Aim();
	void Update();
	void SetOrbitControl();
	void SetManualControl();
	void SetDockControl();
	void SetTargetPlanet(int target) {
		TargetPlanet = target;
	}
	void TryToDock();
};

#undef ONE_ENT

extern Player player;

#endif